package com.web44.springmvc.config;

import com.web44.springmvc.filter.CrosFIlter;
import jakarta.servlet.Filter;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;

/**
 * @Title: ServletConfig
 * @Description:
 * @Auther: py
 * @Version: 1.0
 * @create 2024/1/12 11:22
 */
public class ServletConfig extends AbstractAnnotationConfigDispatcherServletInitializer {
    /**
     * 加载spring配置文件
     * @return
     */
    @Override
    protected Class<?>[] getRootConfigClasses() {
        return new Class[]{SpringConfig.class};
    }

    /**
     * 加载springmvc 配置文件
     * @return
     */
    @Override
    protected Class<?>[] getServletConfigClasses() {
        return new Class[]{SpringMvcConfig.class};
    }

    /**
     * 映射
     * @return
     */
    @Override
    protected String[] getServletMappings() {
        return new String[]{"/"};
    }

    @Override
    protected Filter[] getServletFilters() {
        return new Filter[]{new CrosFIlter()};
    }
}
